import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home/Home.vue'
import GoodsDetail from '../views/GoodsDetail/GoodsDetail.vue'
import Login from '../views/Login/Login.vue'
import Order from '../views/Order/Order.vue'
import Pay from '../views/Pay/Pay.vue'
import Personal from '../views/Personal/Personal.vue'
import Register from '../views/Register/Register.vue'

Vue.use(VueRouter)

  const routes = [
  {
    path: '/',
    name: 'Home',
    component: Home
  },
  {
    path: '/about',
    name: 'About',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    //这是按需导入（加载）的写法，import是在要用到的时候再加载的，而把import写在文件开头则是一次性导入
    component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
  },
  {
    path:'/goodsdetail',
    name:'GoodsDetail',
    component:GoodsDetail
  },
  {
    path:'/login',
    name:'Login',
    component:Login
  },
  {
    path:'/order',
    name:'Order',
    component:Order,
    meta:{requireAuth:true}
  },
  {
    path:'/pay',
    name:'Pay',
    component:Pay,
    meta:{requireAuth:true}
  },
  {
    path:'/personal',
    name:'Personal',
    component:Personal,
    meta:{requireAuth:true}
  },
  {
    path:'/register',
    name:'Register',
    component:Register
  }
]

const router = new VueRouter({
  routes
})

export default router
